package com.fnfn.sdk.api;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.service.Tag;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;

@Configuration
@EnableSwagger2
public class Swagger2 {

    @Bean
    public Docket createRestApi() {
        return new Docket(DocumentationType.SWAGGER_2).apiInfo(apiInfo()).tags(new Tag("login", "登录"), getTags())
                .select().apis(RequestHandlerSelectors.basePackage("com.fnfn.sdk.api.controller")).paths(PathSelectors.any())
                .build();
    }

    private ApiInfo apiInfo() {
        return new ApiInfoBuilder().title("fnfn-sdk-api-server").description("fnfn-sdk-api-server").version("1.0").build();
    }

    private Tag[] getTags() {
        Tag[] tags = { new Tag("customType", "自定义属性管理模块"), new Tag("system", "系统管理模块") };
        return tags;
    }

}
